﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GMUtilitiesDotNet.General
{
    public abstract class DisposableBase : IDisposable
    {
        #region Overriden Methods
        public void Dispose()
        {
            OnDispose(true);
            GC.SuppressFinalize(this);
        }
        #endregion

        #region Methods
        ~DisposableBase()
        {
            OnDispose(false);
        }

        private void OnDispose(bool pDisposeManaged)
        {
            if (pDisposeManaged)
            {
                OnDisposeManaged();
            }

            OnDisposeNative();
        }

        protected virtual void OnDisposeManaged()
        {
        }

        protected virtual void OnDisposeNative()
        {
        }
        #endregion
    }
}